package de.openlaboratory.elib.controller;

import java.util.List;

import de.openlaboratory.elib.core.LogManager;
import de.openlaboratory.elib.model.library.Library;

public class LibraryDAO extends GenericDAOHibernate<Library, Long>
{
	public LibraryDAO()
	{
		super(Library.class);
	}

	public Long create(Library library)
	{
		Long id = null;
		try
		{
			id = (Long) super.create(library);
		}
		catch (Exception p)
		{
			LogManager.logMessage(p.getMessage());
		}
		
		return id;
	}
	
	public Library find(Long id)
	{
		Library library = null;
		
		try
		{
			library = (Library) super.find(new Library(), id);
			LogManager.logMessage("returning library " + library.getName());
		}
		catch (Exception p)
		{
			LogManager.logMessage(p.getMessage());
		}
		
		return library;
	}
	
	public List<Library> findAll()
	{
		List<Library> libraries = null;

		try
		{
			libraries = (List<Library>) super.findAll(new Library());
		}
		catch (Exception p)
		{
			LogManager.logMessage(p.getMessage());
		}
		return libraries;
	}
}
